import { createStore } from 'vuex'
function intinalState(){
  return {
    token:localStorage.getItem("token") || "",
    username:localStorage.getItem("username") || ""
  }
}
export default createStore({
  state:intinalState(),
  mutations: {
    setToken(state,data){
      state.token=data
      localStorage.setItem("token",data)
    },
    setUsername(state,data){
      state.username=data
      localStorage.setItem("username",data)
    },
    clearUsername(state){
      Object.assign(state,intinalState())
    }
  },
  actions: {
  },
  modules: {
  }
})
